package com.changgou.oauth.interceptor;

import com.changgou.oauth.util.AdminToken;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.context.annotation.Configuration;

/**
 *
 */
@Configuration
public class TokenRequestInterceptor implements RequestInterceptor {
    /**
     * feign执行之前进行拦截
     * @param requestTemplate
     */
    @Override
    public void apply(RequestTemplate requestTemplate) {
        //生成令牌
        String token = AdminToken.adminToken();
        //存入到头文件中
        requestTemplate.header("Authorization","bearer "+token);
    }
}
